package com.geek.javase.ch02.test5;
/*
 *@author wangpeng
 *2025/10/10 22:05
 *@description TODO
 * 怪兽类
 *  属性：
 *  怪兽拥有名称name，等级level，血量blood，攻击力power，防御力defence，种族kind。
 *  方法：
 *  怪兽拥有基本攻击方法attack(Hero h)，死亡判定方法isDead()，获取怪兽信息的方法show()。
 */
public class Monster {

    private String name;
    private int level;
    private double blood;
    private double power;
    private double defence;
    private String kind;


    /**
     * 攻击方法
     * @param h  英雄对象信息
     */
    public void attack(Hero h){
        //计算本回合失血量
        double blood = this.power - h.getDefence();
        if(blood>0){
            h.setBlood(h.getBlood() - blood);
            System.out.println("本回合攻击有效，英雄失血量为："+blood+" ， 英雄剩余血量："+h.getBlood());
        }else{
            System.out.println("本回合攻击无效！");
        }
    }

    /**
     * 死亡判定方法
     * @return  true代表死亡 false代表没死亡
     */
    public boolean isDead(){
        if(this.blood<=0){
            return true;
        }
        return false;
    }

    //获取怪兽信息的方法
    public void show(){
        System.out.println("--------  怪兽信息 --------");
        System.out.println("怪兽名称："+name);
        System.out.println("怪兽级别："+level);
        System.out.println("怪兽血量："+blood);
        System.out.println("怪兽攻击力："+power);
        System.out.println("怪兽防御力："+defence);
        System.out.println("怪兽类别："+kind);
    }

    public Monster() {
    }

    public Monster(String name, int level, double blood, double power, double defence, String kind) {
        this.name = name;
        this.level = level;
        this.blood = blood;
        this.power = power;
        this.defence = defence;
        this.kind = kind;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return level
     */
    public int getLevel() {
        return level;
    }

    /**
     * 设置
     * @param level
     */
    public void setLevel(int level) {
        this.level = level;
    }

    /**
     * 获取
     * @return blood
     */
    public double getBlood() {
        return blood;
    }

    /**
     * 设置
     * @param blood
     */
    public void setBlood(double blood) {
        this.blood = blood;
    }

    /**
     * 获取
     * @return power
     */
    public double getPower() {
        return power;
    }

    /**
     * 设置
     * @param power
     */
    public void setPower(double power) {
        this.power = power;
    }

    /**
     * 获取
     * @return defence
     */
    public double getDefence() {
        return defence;
    }

    /**
     * 设置
     * @param defence
     */
    public void setDefence(double defence) {
        this.defence = defence;
    }

    /**
     * 获取
     * @return kind
     */
    public String getKind() {
        return kind;
    }

    /**
     * 设置
     * @param kind
     */
    public void setKind(String kind) {
        this.kind = kind;
    }

    public String toString() {
        return "Monster{name = " + name + ", level = " + level + ", blood = " + blood + ", power = " + power + ", defence = " + defence + ", kind = " + kind + "}";
    }
}
